﻿@page "/Samples/MasterDetail"
@attribute [TabItemOption(Text = "主从明细")]
@inject NavigationManager NavigationManager
@using BBCore.Application.Service
@using Blazored.FluentValidation;
@using BBCore.Core.Models.Samples
@using BBCore.Server.Components.Pages.Components
@using BBCore.Server.Components.Pages.ZDL_WEB.ZDL
@using BBCore.Application.Interface
@inject IExporterAndImporterService IExporterAndImporterService
@inject DownloadService DownloadService
@inject IGetLoginUserNameService IGetLoginUserNameService
@inject AuthenticationStateProvider AuthenticationStateProvider

@* @attribute [Authorize(Policy = BBCore_Constant.policy_IsAdmin)] *@

@* <div class="alert alert-info" style="height:50px">
    <h6 style="text-align:center">主从明细表创建</h6>
</div> *@
<Divider Text="查询栏" Alignment="Alignment.Left" />
<Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Inline">
    <BootstrapInput PlaceHolder="请输入流水号" TValue="string" IsSelectAllTextOnFocus="true" @bind-Value=p_find DisplayText="请输入流水号" />
    <Button Text="查询" Color="Color.Primary" TooltipText="左边输入流水号" OnClick="@Query" IsDisabled="IsDisabled" />
</Row>
测试数据：ZKD　020702151
<Divider Text="操作栏" Alignment="Alignment.Left" />
<ValidateForm Model="Model" OnValidSubmit="OnValidSubmit">
    <p style="color: red;">
        <FluentValidationValidator />
        <ValidationSummary />
    </p>
    <Row ItemsPerRow="ItemsPerRow.Six" RowType="RowType.Inline">
       @*  <Get_Org @bind-ORGID="Model.ORG_ID"></Get_Org> *@
        <BootstrapInput @bind-Value="@Model.JOB_NO" ShowLabel="true" style="width:50px" IsSelectAllTextOnFocus="true" tabindex="1" />
        <BootstrapInputNumber @bind-Value="Model.QUANTITY" ShowLabel="true" tabindex="2" />
        <BootstrapInputToUpper @bind-Value="Model.LINE_CODE" ShowLabel="true" tabindex="3" />
        <DateTimePicker @bind-Value="Model.REQ_DATE" ShowLabel="true" DateFormat="yyyy-MM-dd" tabindex="4" />
        <BootstrapInput @bind-Value="KingNo" DisplayText="流水号" Readonly="true" IsSelectAllTextOnFocus="true" />
    </Row>
    <hr />
    <div style="height: 550px;overflow:auto;">
        @* IsFixedHeader 这个有可能导致select显示不全 搜索固定表头关键字*@
        <Table TItem="ZDL_HYJ_DETAIL_BODY" ShowDefaultButtons="false" ShowExtendButtons="true" ShowExtendEditButton="false" ShowExtendDeleteButton="false"
               ShowLineNo="true" IsFixedHeader="false" FixedExtendButtonsColumn="true" IsBordered="true"
               ShowToolbar="true" Items="Model.ZBJB_ITEMS" ShowRefresh="false">
            <TableColumns>
                <TableColumn @bind-Field="@context.ITEM">
                    <Template Context="v">
                        <BootstrapInput @bind-Value="v.Row.ITEM" IsSelectAllTextOnFocus="true"  @onfocusout="e=>((ZDL_HYJ_DETAIL_BODY)v.Row).ITEM=v.Row.ITEM" OnBlurAsync="e=>Item_ValueChangeAsync(((ZDL_HYJ_DETAIL_BODY)v.Row),v.Row.ITEM)" />
                        @* <p style="color: red;"><ValidationMessage For="@(() =>v.Row.ITEM)" /></p>  *@
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.DESCRIPTION">
                    <Template Context="v">
                        <BootstrapInput @bind-Value="v.Row.DESCRIPTION" Readonly=true @onfocusout="e=>((ZDL_HYJ_DETAIL_BODY)v.Row).DESCRIPTION=v.Row.DESCRIPTION" />
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.ITEM_TYPE">
                    <Template Context="v">
                        <BootstrapInput @bind-Value="v.Row.ITEM_TYPE" Readonly=true @onfocusout="e=>((ZDL_HYJ_DETAIL_BODY)v.Row).ITEM_TYPE=v.Row.ITEM_TYPE" />
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.LEVEL2">
                    <Template Context="v">
                        <BootstrapInput @bind-Value="v.Row.LEVEL2" @ref="inputLEVEL2" IsSelectAllTextOnFocus="true" @onfocusout="e=>((ZDL_HYJ_DETAIL_BODY)v.Row).LEVEL2=v.Row.LEVEL2" />
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.JOB2">
                    <Template Context="v">
                        <BootstrapInput @bind-Value="v.Row.JOB2" IsSelectAllTextOnFocus="true" @onfocusout="e=>((ZDL_HYJ_DETAIL_BODY)v.Row).JOB2=v.Row.JOB2" />
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.LEVEL_ENUMS">
                    <Template Context="v">
                        <Select Value="v.Value" TValue="Level_enum" ValueChanged="d=>((ZDL_HYJ_DETAIL_BODY)v.Row).LEVEL_ENUMS=d" />
                    </Template>
                </TableColumn>
                <TableColumn @bind-Field="@context.CREATED_DATE">
                    <Template Context="v">
                        <DateTimePicker Value="v.Value" TValue="DateTime" tabindex="15" ValueChanged="t=>((ZDL_HYJ_DETAIL_BODY)v.Row).CREATED_DATE=t" />
                    </Template>
                </TableColumn>
            </TableColumns>
            <TableToolbarTemplate>
                @* <Button Text="新增" TItem="ZDL_HYJ_DETAIL_BODY" OnClick="()=> Model!.ZBJB_ITEMS!.Add(new ZDL_HYJ_DETAIL_BODY())" /> *@
                <div class="btn-group" role="group">
                    <Button Text="新增" TItem="ZDL_HYJ_DETAIL_BODY" OnClick="AddNewRow" />
                    <Button Text="模板下载" Color="Color.Info" OnClick="tempDownload"></Button>
                    <ButtonUpload TValue="string" ShowUploadFileList="false" BrowserButtonClass="btn-secondary" BrowserButtonText="导入" OnChange="DataImport" />                    
                </div>
            </TableToolbarTemplate>

            <RowButtonTemplate>
                <TableCellButton Color="Color.Danger" Text="删除" OnClick="()=>Model!.ZBJB_ITEMS!.Remove(context)" />
            </RowButtonTemplate>

        </Table>
    </div>
    <div style="text-align:center;padding:10px;">
        <PopConfirmButton Placement="Placement.Top" Color="Color.Primary" ConfirmIcon="fa fa-exclamation-triangle text-info"
                          ConfirmButtonColor="Color.Success" Text="提交表单" Content="确定提交数据吗？" Icon="fa fa-save fa-fw"
                          ButtonType="ButtonType.Submit" IsAsync="true" />
        <Button ButtonType="ButtonType.Button" Icon="fa fa-repeat" Color="Color.Danger" Text="重置" OnClick="e=>RefreshPage()"></Button>
    </div>
</ValidateForm>



